package com.example.dragandview.recyclerviewplus.adapters;


import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.dragandview.R;
import com.example.dragandview.recyclerviewplus.beans.ItemBean;

import java.util.List;

public class GridViewAdapter extends RecyclerViewBaseAdaptar {
    public GridViewAdapter(List<ItemBean> data) {
        super(data);
    }

    @Override
    protected View getSubView(ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.recyclerviewpro_gridview, null);
        return view;
    }

    /*
    protected List<ItemBean> itemBeans;

    public GridViewAdapter(List<ItemBean> itemBeans) {
        this.itemBeans = itemBeans;
    }

    @NonNull
    @Override
    public InnerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = View.inflate(parent.getContext(), R.layout.recyclerviewpro_gridview,null);
        return new InnerHolder(itemview);
    }

    @Override
    public void onBindViewHolder(@NonNull InnerHolder holder, int position) {
        holder.setDatas(itemBeans.get(position));
    }

    @Override
    public int getItemCount() {
        return itemBeans == null ? 0 : itemBeans.size() ;
    }

    public class InnerHolder extends RecyclerView.ViewHolder {
        private ImageView iv;
        private TextView tv;
        public InnerHolder(@NonNull View itemView) {
            super(itemView);
            iv = itemView.findViewById(R.id.rv_grid_icon);
            tv = itemView.findViewById(R.id.rv_grid_title);
        }

        public void setDatas(ItemBean itemBean) {
            iv.setImageResource(itemBean.icon);
            tv.setText(itemBean.title);
        }
    }*/

}
